﻿using System;
using System.Windows.Input;

namespace PasswordControl.UI.WPF.ViewModel
{
    abstract class CommandBase<ViewModelType> : ICommand
    {
        public event EventHandler CanExecuteChanged;

        protected ViewModelType ViewModel { get; private set; }

        public CommandBase(ViewModelType viewModel)
        {
            ViewModel = viewModel;
        }

        public virtual bool CanExecute(object parameter)
        {
            return true;
        }

        public virtual void CanExecuteChangedNotify()
        {
            var canExecuteChanged = CanExecuteChanged;
            if (canExecuteChanged != null) canExecuteChanged(this, new EventArgs());
        }

        public abstract void Execute(object parameter);
    }
}
